package com.nancy.java_design.visitor.demo1;

/**
 * 访问者模式
 */
public class Client {
    public static void main(String[] args) {
        // 创建结构对象
        VisitorStructure visitorStructure = new VisitorStructure();

        // 创建元素
        Animal dog = new Dog();
        visitorStructure.add(dog);
        Animal cat = new Cat();
        visitorStructure.add(cat);

        // 创建访问者
        Visitor visitor = new Owner();
        visitorStructure.accept(visitor);
        System.out.println("---------------------");
        Visitor visitor2 = new Someone();
        visitorStructure.accept(visitor2);

    }
}
